package com.example.demo.controller;

import com.alibaba.druid.support.json.JSONUtils;
import com.example.demo.bean.SysConfig;
import com.example.demo.bean.SysRole;
import com.example.demo.dao.SysRoleDao;
import generate.SysConfigDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/demo")
public class HelloController {

    @GetMapping("hello")
    public String hello(){
        return "hhh";
    }

    @GetMapping("list")
    public String configList(){
            List<SysConfig> list = sysConfigDao.selectAll(null);
        System.out.println(list);
            return list.toString();
    }

    @GetMapping("roles")
    public String roles(){
        List<SysRole> list = sysRoleDao.select();
        System.out.println(list);
        return list.toString();
    }

    @GetMapping("id")
    public String configId(){
        SysConfig list = sysConfigDao.selectByPrimaryKey(1L);
        return JSONUtils.toJSONString(list);
    }

    @Autowired
    private SysConfigDao sysConfigDao;

    @Autowired
    private SysRoleDao sysRoleDao;
}
